// Chaingun (Doom)

ACTOR IDMChaingun : IDMWeapon
{
	//Weapon.PreferredSkin "ChaingunMarine"
	Weapon.Sisterweapon "IDMChaingunLevel2"
	Weapon.SelectionOrder 800
	Weapon.KickBack 100
	Weapon.AmmoUse 1
	Weapon.AmmoGive 40
	Weapon.AmmoType "IDMClip"
	Inventory.PickupMessage "Chaingun! (Slot 4)"
	Obituary "%o was perforated by %k's Chaingun."
	Attacksound "weapons/Pistol"
	Tag "Chaingun"
	Damagetype "Bullet"
	Decal Bulletchip
	+WEAPON.ALLOW_WITH_RESPAWN_INVUL
	+WEAPON.NOLMS
	States
	{
	Ready:
      CHGG A 1 A_WeaponReady
	  Loop
	Deselect:
      TNT1 A 0 A_Lower
      TNT1 A 0 A_Lower
      CHGG A 1 A_Lower
      Loop
	Select:
	  TNT1 A 0 A_PlaySound("weapons/wswitch",CHAN_WEAPON)
	Sloop:
      TNT1 A 0 A_Raise
      TNT1 A 0 A_Raise
      CHGG A 1 A_Raise
      Loop
	Fire:
	Normal:
      TNT1 A 0 A_JumpIfInventory("PowerQuadDamage", 1, "Quad")
      TNT1 A 0 A_GunFlash
      CHGG A 4 A_FireBullets(4.2, 3.55, random(1,2), 10,"IDMBulletPuff")
	  TNT1 A 0 A_JumpIfNoAmmo("Unspool")
	Normal2:
      TNT1 A 0 A_JumpIfInventory("PowerQuadDamage", 1, "Quad2")
      TNT1 A 0 A_GunFlash("Flash2")
      CHGG B 4 A_FireBullets(4.2, 3.55, random(1,2), 10,"IDMBulletPuff")
	  TNT1 A 0 A_JumpIfNoAmmo("Unspool")
	  TNT1 A 0 A_Refire("Normal")
	Unspool:
	  CHGG AB 5 A_Refire("Normal")
	  Goto Ready
	Quad:
	  TNT1 A 0 A_Playsound("misc/qdmg2",CHAN_5)
      TNT1 A 0 A_GunFlash
      CHGG A 4 A_FireBullets(4.2, 3.55, random(1,2), 10,"ExtremePuff")
	  TNT1 A 0 A_JumpIfNoAmmo("Unspool")
	  Goto Normal2
	Quad2:
	  TNT1 A 0 A_Playsound("misc/qdmg2",CHAN_5)
      TNT1 A 0 A_GunFlash("Flash2")
      CHGG B 4 A_FireBullets(4.2, 3.55, random(1,2), 10,"ExtremePuff")
	  TNT1 A 0 A_JumpIfNoAmmo("Unspool")
	  TNT1 A 0 A_Refire("Normal")
	  Goto Unspool
	Flash:
      CHGF A 5 Bright A_Light1
	  Goto LightDone
	Flash2:
      CHGF B 5 Bright A_Light2
	  Goto LightDone
	Spawn:
      MGUN A -1 Bright
      Stop
    }
}

ACTOR IDMChaingunLevel2 : IDMChaingun
{
	+POWERED_UP
	+WEAPON.CHEATNOTWEAPON
	Weapon.AmmoGive 0
	Weapon.AmmoUse 1
	//Weapon.PreferredSkin "DualChaingunMarine"
	Weapon.Sisterweapon "IDMChaingun"
	Damagetype "Bullet"
	Tag "Chaingun"
	States
	{
	Ready:
      CHG2 A 1 A_WeaponReady
	  Loop
	Deselect:
      TNT1 A 0 A_Lower
      TNT1 A 0 A_Lower
      CHG2 A 1 A_Lower
      Loop
	Select:
	  TNT1 A 0 A_PlaySound("weapons/wswitch",CHAN_WEAPON)
	Sloop:
      TNT1 A 0 A_Raise
      TNT1 A 0 A_Raise
      CHG2 A 1 A_Raise
      Loop
	Fire:
	Normal:
      TNT1 A 0 A_JumpIfInventory("PowerQuadDamage", 1, "Quad")
      TNT1 A 0 A_GunFlash
      CHG2 A 4 A_FireBullets(4.8, 3.55, random(2,6), 10,"IDMBulletPuff")
	  TNT1 A 0 A_JumpIfNoAmmo("Unspool")
	Normal2:
      TNT1 A 0 A_JumpIfInventory("PowerQuadDamage", 1, "Quad2")
      TNT1 A 0 A_GunFlash("Flash2")
      CHG2 B 4 A_FireBullets(4.8, 3.55, random(2,6), 10,"IDMBulletPuff")
	  TNT1 A 0 A_JumpIfNoAmmo("Unspool")
	  TNT1 A 0 A_Refire("Fire")
	Unspool:
	  CHG2 ABA 4
	  CHG2 BA 5
	  Goto Ready
	Quad:
	  TNT1 A 0 A_Playsound("misc/qdmg2",CHAN_5)
      TNT1 A 0 A_GunFlash
      CHG2 A 4 A_FireBullets(4.9, 3.55, random(2,6), 10,"ExtremePuff")
	  TNT1 A 0 A_JumpIfNoAmmo("Unspool")
	  Goto Normal2
	Quad2:
	  TNT1 A 0 A_Playsound("misc/qdmg2",CHAN_5)
      TNT1 A 0 A_GunFlash("Flash2")
      CHG2 B 4 A_FireBullets(4.9, 3.55, random(2,6), 10,"ExtremePuff")
	  TNT1 A 0 A_JumpIfNoAmmo("Unspool")
	  TNT1 A 0 A_Refire("Fire")
	  Goto Unspool
	Flash:
      CH2F A 5 Bright A_Light1
	  Goto LightDone
	Flash2:
      CH2F B 5 Bright A_Light2
	  Goto LightDone
	}
}